package second;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Enumeration;


public class UrlPara extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		response.setContentType("text/html;charset=gbk");
		PrintWriter out=response.getWriter();
		out.println("<html>");
		out.println("<head>");
		out.println("<title>Servlet取得URL参数</title>");
		out.println("</head>");
		out.println("<body>");
		Enumeration<String> e=request.getParameterNames();
		if(e.hasMoreElements()) {
			while(e.hasMoreElements()) {
				String name=e.nextElement();
				String value=request.getParameter(name);
				if(value==null) {
					value="";
				}
				out.println("<p>");
				out.println("参数名：");
				out.println("name");
				out.println("&nbsp;参数值：");
				out.println(value);
				out.println("</p>");
			}
		}else {
			out.println("<p>");
			out.println("当前请求无URL参数");
			out.println("</p>");
		}
		out.println("</body>");
		out.println("</html>");
		
	}
}
